
global x86InitIDT	; make symbol able to be found by the linker

%macro EXCEPTION_NOERRCODE 1    ; define a macro, taking one parameter.
    global isr%1
    isr%1:
      cli                         ; Disable interrupts firstly.
      push 0                      ; Push a dummy error code.
      push %1                     ; Push the interrupt number.
      jmp exception_common_stub   ; Go to out common handler code.
%endmacro

%macro EXCEPTION_ERRCODE 1
    global isr%1
    isr%1:
      cli                         ; Disable interrupts.
      push %1                     ; Push the interrupt number
      jmp exception_common_stub
%endmacro

struc   idt_entry_t                     ; its structure 
        .base_lo   resw    1 ; The lower 16 bits of the address to jump to.
        .sel       resw    1 ; Kernel segment selector.
        .always0   resb    1 ; This must always be zero.
        .flags     resb    1 ; More flags. See documentation.
        .base_hi   resw    1 ; The upper 16 bits of the address to jump to.
endstruc

struc   idt_ptr_t
        .limit  resw    1
        .base   resd
endstruc

EXCEPTION_NOERRCODE 0
EXCEPTION_NOERRCODE 1
EXCEPTION_NOERRCODE 2
EXCEPTION_NOERRCODE 3
EXCEPTION_NOERRCODE 4
EXCEPTION_NOERRCODE 5
EXCEPTION_NOERRCODE 6
EXCEPTION_NOERRCODE 7
EXCEPTION_ERRCODE   8
EXCEPTION_NOERRCODE 9

exception



SECTION .bss
alignb 4
idt_entries:  resb 256 * 8
idt_ptr:      resb 6 
